<template>
  <div class="pop-box-parent" :style="props.styleS">
    <div class="pop-box">
      <div class="shadow-box" v-if="publishType !== 3">
        <div class="shadow-box-content">
          <span>发布后即可分享</span>
          <div class="shadow-box-shadow"></div>
        </div>
      </div>
      <span class="title">分享</span>
      <div class="qrcode-box">
        <QRCodeVue :value="getWapUrl" :size="136" level="H"></QRCodeVue>
        <div class="QRCode-tiitle">
          <i class="doorIcon">&#xe624;</i>

          <span>微信扫码查看</span>
        </div>
      </div>
      <div class="solid-box"></div>
      <div class="pop-menu">
        <i class="doorIcon" @click.stop="shearIndex(1)">&#xe627;</i>
        <i class="doorIcon" @click.stop="shearIndex(2)">&#xe616;</i>
        <i class="doorIcon" @click.stop="shearIndex(3)">&#xe615;</i>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
// @ts-nocheck
import { projectDetail } from '@/api/project/project';
import { MessagePlugin } from 'tdesign-vue-next';
import { toQQzone, toQQ, toWeibo, toWechat } from '@/utils/shear';
import { cancatUrl, getUrlTemplateId } from '@/utils/minxin';
import { computed, ref } from 'vue';
import QRCodeVue from 'qrcode.vue';
import { useProjectStore } from '@/store';
const props = defineProps({
  styleS: {
    type: Object,
  },
  url: {
    type: String,
  },
  color: {
    type: String,
  },
  background: {
    type: String,
  },
  codeColor: {
    type: String,
  },
});
const publishType = ref(1);
const store = useProjectStore();
const emit = defineEmits(['shearType']);
const shearIndex = (e: number) => {
  let url = window.location.href;

  let title = document.title;
  switch (e) {
    case 1:
      let titleCancat = `【${title} | 记忆网】` + ' ' + url;
      copyText(titleCancat);

      break;
    case 2:
      toQQ(url, title);
      break;
    case 3:
      toWeibo(url, title);
      break;
    default:
      toWechat(url, title);
      break;
  }
  // emit('shearType', e);
};
const copyText = (str: any) => {
  if (!str) {
    return;
  }
  var cInput = document.createElement('input');
  cInput.value = str;
  document.body.appendChild(cInput);
  cInput.select(); // 选取文本框内容
  document.execCommand('copy');

  // 复制成功后再将构造的标签 移除
  document.body.removeChild(cInput);
  MessagePlugin.success('复制成功');
};
const getWapUrl = computed(() => {
  let linkUrl: string = '';
  const projactId = getUrlTemplateId();

  switch (store.styleInfo.id) {
    case 395740859879493:
      linkUrl = `wap/${projactId}/wylx/home`;

      break;
    case 395741054230597:
      linkUrl = `wap/${projactId}/wmlg/home`;

      break;
    case 410276243316805:
      linkUrl = `wap/${projactId}/yyhz/home`;

      break;
    case 410276336631877:
      linkUrl = `wap/${projactId}/qytc`;

      break;
    case 420838252666949: //模板五
      linkUrl = `wap/${projactId}/sjch/timeAxisIndex`;

      break;
    case 420838403928133: //模板6
      linkUrl = `wap/${projactId}/whsy/banner`;

      break;
    case 420838478893125: //模板7
      linkUrl = `wap/${projactId}/wxzg/home/banner`;

      break;
    case 430808400945221: //模板8
      linkUrl = `wap/${projactId}/ygzy/home`;

      break;
    case 436439958675525: //模板9
      linkUrl = `wap/${projactId}/lhcz`;

      break;
    case 435293743870021: //模板10
      linkUrl = `wap/${projactId}/gymj/home`;

      break;
    case 438898951708741: //模板11
      linkUrl = `wap/${projactId}/mxyy/home`;

      break;
    case 503306628902981: //模板14
      linkUrl = `wap/${projactId}/stsy/home`;

      break;
    case 499717623300165: //模板15
      linkUrl = `wap/${projactId}/wjqq/home`;

      break;
    case 505022027386949: //模板16
      linkUrl = `wap/${projactId}/fqxy/home`;

      break;
    case 506862194171973: //模板13
      linkUrl = `wap/${projactId}/cyfh/home`;

      break;
    case 507481625702469: //丹青妙手
      linkUrl = `wap/${projactId}/dqms/banner`;

      break;
    case 529130430058565: //模板19
      linkUrl = `wap/${projactId}/jmyd/home`;
      break;
    default:
      break;
  }
  return cancatUrl + linkUrl;
});
const initName = async () => {
  try {
    let res = await projectDetail(localStorage.getItem('projectId'));
    // alert(res.data.subTitle);

    publishType.value = res.data.publishStatus;
  } catch {}
};
initName();
</script>

<style lang="less" scoped>
.pop-box-parent {
  position: relative;
  width: 240px;
  margin-bottom: 65px;
  z-index: 996;
  box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.1), 0px 8px 10px 1px rgba(0, 0, 0, 0.06),
    0px 3px 14px 2px rgba(0, 0, 0, 0.05);
}
.pop-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 240px;
  height: 294px;
  // margin-top: 30px;
  background: #ffffff;

  // box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.1), 0px 8px 10px 1px rgba(0, 0, 0, 0.06),
  //   0px 3px 14px 2px rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  padding: 16px;
}
.shadow-box {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;

  .shadow-box-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 100%;
  }
  .shadow-box-shadow {
    position: absolute;
    top: 0;
    left: 0;
    background: rgba(255, 255, 255, 0.95);
    // filter: blur(8px);
    width: 100%;
    height: 100%;
  }
  // filter: blur(8px);
  span {
    position: relative;
    z-index: 20;
    font-family: PingFangSC, PingFang SC;
    font-weight: 500;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.59);
    line-height: 24px;
  }
}
.title {
  margin-bottom: 16px;
}
.qrcode-box {
  display: flex;
  flex-direction: column;
  width: 136px;
}
.QRCode-tiitle {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 8px;
  span {
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.38);
    line-height: 22px;
    margin-left: 4px;
  }
  .doorIcon {
    font-size: 14px;
    line-height: 14px;
    color: rgba(0, 0, 0, 0.38) !important;
  }
}
.solid-box {
  width: 208px;
  height: 16px;
  box-shadow: inset 0px -1px 0px 0px #f0f0f0;
  margin-bottom: 16px;
}
.pop-menu {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 44px;
  .doorIcon {
    cursor: pointer;
    font-size: 24px;
    color: rgba(0, 0, 0, 0.38) !important;
  }
}
</style>
